package dao.Impl;

import dao.GradeDao;
import po.College;
import po.Grade;
import util.DBUtils;
import util.DaoRepeat;

import java.sql.SQLException;
import java.util.List;

public class GradeDaoImpl extends BaseDaoImpl<Grade>  implements GradeDao {
    @Override
    public boolean insert(Grade grade) {
        try {
            insert(grade, DBUtils.getConnection());
        } catch (SQLException e) {
            e.printStackTrace();
        }return true;
    }

    @Override
    public boolean delete(Grade grade) {
        try {
            delete(grade,DBUtils.getConnection());
        } catch (SQLException e) {
            e.printStackTrace();
        }return  true;
    }

    @Override
    public boolean update(Grade grade) {
        try {
            update(grade,DBUtils.getConnection());
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return  true;
    }

    @Override
    public Grade queryOne(Integer id) {
        Grade grade = queryOne("select * from Grade where id=?", Grade.class, id);
        return  grade;
    }

    @Override
    public List<Grade> queryAll(Integer cid) {
        List<Grade> grades = queryMany("select * from Grade where cid=?", Grade.class, cid);
        return  grades;
    }
}
